<template>
	<view v-if="openList==[]">
		<xbd-zwnz marginTop='200'></xbd-zwnz>
	</view>
	<view v-else class="center">
		<view class="popup-card">
			<view class="titles">
				<view class="left">

				</view>
				<view class="">
					{{openTitle.name}}
				</view>
			</view>
			<view class="right">
				<image v-if="openTitle.state=='not'" class="images" src="@/static/image/mission/wwc.png" ></image>
				<image v-if="openTitle.state=='end'" class="images" src="@/static/image/mission/pass.png" ></image>
			</view>
			<view class="list">
				<view class="card" @click="clickDetail(item.id)" v-for="(item,index) in openList" :key="index">
					<view :class="['point', item.state === 'not'? '':'color']"></view>
					<view class="">
						<view class="title">
							<view class="name">
								{{item.name}}
							</view>
						</view>
						<view v-if="item.state!== 'not'">
							<text>完成</text>
							<text class="time">{{item.time | timeFormat('YYYY-MM-DD HH:mm')}}</text>
						</view>
					</view>

				</view>
			</view>

		</view>
	</view>

</template>

<script>
	import {
		Mission
	} from '@/api/index.js';
	export default {
		data() {
			return {
				farId: '',
				openTitle: {
					name: '',
					state: ''
				},
				st:'',
				opId:'',
				openList: []
			}
		},
		methods: {
			clickDetail(val) {
				uni.navigateTo({
					url: `/pages/mission/myTask/details?farId=${this.opId}&id=${val}&st=${this.st}`,
				});

			},
			async init() {
				const req = await Mission.getCompleteList(this.farId)
				if(req.success){
					this.openList = req.data.knowledge;
					this.openTitle.state = req.data.state
					this.opId = req.data._id
				}else{
					this.$showToast(req.msg);
				}
			}
		},
		async onLoad(res) {
			this.st=res.st
			console.log(res)
			this.openTitle.name = res.name
			this.farId = res.id
			
			await this.init()
		},
		onShow(){
			this.init()
		}
	}
</script>

<style lang="scss" scoped>
	::v-deep .uni-easyinput__content-input {
		font-size: 30rpx;
	}
	.center {
		padding: 32rpx;
	}

	.titles {
		margin-top: 24rpx;
		margin-left: -32rpx;
		display: flex;
		align-items: center;
		font-size: 32rpx;
		font-weight: 800;

		.left {
			width: 10rpx;
			height: 28rpx;
			background-color: #2E73FC;
			border-top-right-radius: 10rpx;
			border-bottom-right-radius: 10rpx;
			margin-right: 24rpx;
		}
	}

	.popup-card {
		position: relative;
		box-sizing: border-box;
		border-radius: 12rpx;
		border-radius: 12rpx;
		background-color: #FFFFFF;
		padding: 32rpx;
		.images {
			width: 100rpx;
			height: 88rpx;
		}

		.right {
			position: absolute;
			top: 32rpx;
			right: 24rpx;
		}


		.card {
			display: flex;
			padding: 40rpx 0;
			border-bottom: 4rpx dashed #E5E5E5;
			font-size: 26rpx;
			color: #A0A7B8;

			.title {
				display: flex;
				color: #000623;
				font-size: 26rpx;
				margin-bottom: 20rpx;
				.name{
					max-width: 500rpx;
					overflow: hidden; 
					white-space: nowrap; 
					text-overflow: ellipsis;
				}
			}

			.time {
				margin-left: 20rpx;
			}

			.point {
				margin: 12rpx 20rpx 0 0;
				width: 16rpx;
				height: 16rpx;
				border-radius: 8rpx;
				background-color: #FCB94F;
			}

			.color {
				background-color: #48BC7C !important;
			}


			// &:nth-last-child(1) {
			// 	border-bottom: none;
			// }
		}
	}
</style>
